<%@page import="java.util.UUID"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglib.jsp" %>
<%
    String uuid = UUID.randomUUID().toString();
    request.setAttribute("uuid", uuid);
%>
<div id="${uuid}_layout">
	<div id="${uuid}_mainTableGridTb">
		<button class="btn btn-default selectBtn">
   			<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 选择|双击行选择
   		</button>
	</div>
	<table id="${uuid}_mainTableGrid">
	</table>
</div>

<script type="text/javascript">
$(function(){
	var uuid = '${uuid}';
	
	var mainTableGrid=$("#" + uuid + "_mainTableGrid").bootstrapTable({
		url: ctx + "/formTableDefineAction/queryValidMainTable.do",
		columns: [
                   {field: '_id', checkbox: true},
                   {title: '表编码', field: 'tableCode', align: 'left', width: 120},
                   {title: '表英文名', field: 'tableName', align: 'left', width: 120},
                   {title: '表描述', field: 'tableDesc', align: 'left', width: 120}
               ],
        toolbar: "#"+uuid+"_mainTableGridTb",
        height:$(window).height()*0.7,
        onDblClickRow:function(row, $element){
        	top.webUtils.topicPublish("selectMainTable.selected", row);
        }
	});
	
	var _mainTableGridTb=$("#"+uuid+"_mainTableGridTb");
	_mainTableGridTb.find(".selectBtn").click(function(){
		var rows = mainTableGrid.bootstrapTable("getSelections");
        if (!rows || rows.length <= 0) {
            webUtils.alert("请选择数据");
        } else {
            top.webUtils.topicPublish("selectMainTable.selected", rows[0]);
        }
	});
	
});
</script>